#include<iostream>
#include<string>
using namespace std;
const int N = 1010;
typedef long long ll;
int a[N][N];
ll d[N][N];   //差分数组
//在子矩阵里面+c
void insert(int x1,int y1,int x2,int y2,int c)
{
    //差分数组 四点背下来
    d[x1][y1]+=c;   d[x1][y2+1]-=c;
    d[x2+1][y1]-=c; d[x2+1][y2+1]+=c;
}
int main()
{
    int n, m;
    ll q;
    cin >> n >> m>>q;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cin >> a[i][j]; 
            insert(i,j,i,j,a[i][j]);
        }
    }
    //在子矩阵加c
    while (q--)
    {
        int x1, y1, x2, y2,c;
        cin >> x1 >> y1 >> x2 >> y2>>c;
        insert(x1,y1,x2,y2,c);
    }
    //计算差分数组的前缀和(就是最终矩阵)
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            //也可以开一个s,但是没必要
            //左+上-左上+自己(这里d[i]是前缀和了，前面也是变前缀和)
            d[i][j]=d[i][j-1]+d[i-1][j]-d[i-1][j-1]+d[i][j];
            cout<<d[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}